import * as types from '../types';

export default function (state = {list: []}, action) {
    if (action === undefined) return state;
    switch (action.type) {
        case types.ADD_TODO://增加todo
            return {list: [...state.list, action.text]};
        case types.DEL_TODO:
            return {list: state.list.filter((item, index) => index !== action.index)};
        default:
            return state;
    }
}